﻿<%@ Page Culture="auto" UICulture="auto" Title="Auto complete value handler" EnableEventValidation="false"
    Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="AutoCompleteExamplePage.aspx.cs"
    Inherits="BM.Tools.WebControls.MForm.Example.ValueHandlers.AutoCompleteExamplePage" %>

<%@ Register Assembly="BM.Tools.WebControls.MForm" Namespace="BM.Tools.WebControls.MForm.Controls.ValueHandlers"
    TagPrefix="mfvh" %>
<%@ Register Assembly="BM.Tools.WebControls.MForm" Namespace="BM.Tools.WebControls.MForm.Controls.Additions"
    TagPrefix="mfadd" %>
<%@ Register Assembly="BM.Tools.WebControls.MForm" Namespace="BM.Tools.WebControls.MForm.Controls"
    TagPrefix="mf" %>
<%@ Register TagPrefix="mftitle" Namespace="BM.Tools.WebControls.MForm.Controls.Titles"
    Assembly="BM.Tools.WebControls.MForm" %>
<asp:Content ContentPlaceHolderID="Demonstration" runat="server">
    <p>
        The following demonstration shows two auto-complete value handlers: one that only
        accepts responses coming from the auto-complete service, and the other that accepts
        any text provided
    </p>
    <mf:RootValidator runat="server" ControlToValidate="Root1" />
    <mf:Root ID="Root1" runat="server">
        <Contents>
            <mf:Branch Name="TheForm" runat="server">
                <Contents>
                    <mf:Branch Name="Data" runat="server" MinOccurs="1" MaxOccurs="20">
                        <Contents>
                            <mf:Leaf Name="ValidatedAutoCompleteLeaf" runat="server">
                                <ValueHandler>
                                    <mfvh:AutoCompleteValueHandler AcceptResponsesOnly="true" runat="server">
                                        <Extender MinimumPrefixLength="1" ServicePath="../AutoComplete/AutoComplete.asmx"
                                            ServiceMethod="GetCountries" />
                                    </mfvh:AutoCompleteValueHandler>
                                </ValueHandler>
                            </mf:Leaf>
                            <mf:Leaf Name="NotValidatedAutoCompleteLeaf" runat="server">
                                <ValueHandler>
                                    <mfvh:AutoCompleteValueHandler runat="server">
                                        <Extender MinimumPrefixLength="1" ServicePath="../AutoComplete/AutoComplete.asmx"
                                            ServiceMethod="GetCountries" />
                                    </mfvh:AutoCompleteValueHandler>
                                </ValueHandler>
                            </mf:Leaf>
                            <mf:Leaf Name="OtherLeaf" runat="server" />
                        </Contents>
                    </mf:Branch>
                </Contents>
            </mf:Branch>
        </Contents>
    </mf:Root>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="Description" runat="server">
    <p>
        The <code>AutoCompleteValueHandler</code> is a value handler written for the AjaxControlToolkit
        AutoComplete extender.
    </p>
    <p>
        The value handler takes care of cloning the AutoComplete client-side extender in
        case the element (you can see that if you add another 'Data' element to the form
        - the newly created leafs will have working auto complete functionality).
    </p>
    <div class="Section">
        <mftitle:TitleControl runat="server" Text="The <code>Extender</code> property." />
        <p>
            To define the AutoComplete extender behavior, the <code>Extender</code> property
            should be changed.
        </p>
        <div class="Remark">
            <p>
                More about the <code>AutoCompleteExtender</code> can be found
                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx"
                    Text="here" /></p>
        </div>
    </div>
    <div class="Section">
        <mftitle:TitleControl runat="server" Text="The <code>AcceptResponsesOnly</code> property." />
        <p>
            The AutoComplete functionality can be used in two different situations
        </p>
        <ul>
            <li>1) As a convenient substitution of a dropdown list</li>
            <li>2) As a text box with hints</li>
        </ul>
        <p>
            In the first situation values other than those suggested by the auto complete extender
            should not be accepted. Besides, in such a situation the text in the control and
            the value that it keeps do not necessarily need to be the same.
        </p>
        <p>
            In the second situation values suggested by the extender can only be treated as
            hints and are not obligatory. In such a case the text in the control is the actual
            value.
        </p>
        <p>
            The <code>AutoCompleteValueHandler</code> can handle both situations. The validating
            behavior can be achieved by setting the value handler's <code>AcceptResponsesOnly</code>property
            to true. The hinting behavior will work when the <code>AcceptResponsesOnly</code>
            property is set to false (it is the default value).
        </p>
    </div>
</asp:Content>
